#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> num(n + 1, 0);
    vector<long long> dp(n + 1, 0);

    for (int i = 1; i < n + 1; i++)
    {
        cin >> num[i];
        dp[i] = dp[i - 1] + num[i];
    }

    for (int i = 0; i < q; i++)
    {
        int left, right;
        cin >> left >> right;

        long long sum = dp[right] - dp[left - 1];

        cout << sum << endl;
    }

    return 0;
}